| Name | Description | URL (path) |
|---|---|---|
| oct18_N | Cities survey results geopackages | https://drive.google.com/file/d/1VV5nxWja2sA5jbKpHIgdVsE2Ie393QYH/view?usp=sharing |
| 200601 New Polygons final upload | New polygons (5 folders) | https://drive.google.com/drive/folders/1dVyhXth5rYxvod10N16tDeF_Qvo5I8fz?usp=sharing |
| Missing Polygons | Feb2021 - Missing Polygons | https://drive.google.com/drive/u/0/folders/1z6yo7E6avS_3HPTNXO7M6f-q-ePDNhBy |
oct18 <- st_read("/Users/nicolas/Documents/R_GitHub/sind/oct18_N.gpkg")
Reading layer masterGJ' from data source/Users/nicolas/Documents/R_GitHub/sind/oct18_N.gpkg’ using driver `GPKG’ Simple feature collection with 2515 features and 100 fields (with 458 geometries empty) geometry type: MULTIPOLYGON dimension: XY bbox: xmin: 531305.5 ymin: 171277 xmax: 536322.5 ymax: 180434.8 projected CRS: unnamed
FUCs
oct18 %>%
st_drop_geometry() %>%
select(X3_Functional_Unit_Co) %>%
rename(FUC = X3_Functional_Unit_Co) %>%
summarise(Total = n(),
FUCs = n_distinct(FUC),
NA_FUCs = sum(is.na(FUC))) %>%
adorn_totals()
Valid/empty geometries?
st_is_empty(oct18) -> l1
length(l1[l1 == TRUE])
[1] 458
Some FUCs are duplicated?
oct18 %>%
select(X3_Functional_Unit_Co) %>%
rename(FUC = X3_Functional_Unit_Co) %>%
st_drop_geometry() %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) %>%
adorn_totals()
FUCs
npol %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
summarise(Total = n(),
FUCs = n_distinct(FUC),
NA_FUCs = sum(is.na(FUC))) %>%
adorn_totals()
Valid/empty geometries?
st_is_empty(npol) -> l2
length(l2[l2 == TRUE])
[1] 0
Some FUCs are duplicated?
npol %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) %>%
adorn_totals()
FUCs
mpol %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
summarise(Total = n(),
FUCs = n_distinct(FUC),
NA_FUCs = sum(is.na(FUC))) %>%
adorn_totals()
Valid/empty geometries?
#st_is_empty(mpol) -> l3
#length(l3[l3 == TRUE])
Error in CPL_geos_is_empty(st_geometry(x)) : Evaluation error: IllegalArgumentException: Points of LinearRing do not form a closed linestring.
Some FUCs are duplicated?
mpol %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) %>%
adorn_totals()
Identify invalid feature
mpol %>%
st_is_valid() -> valid
(valid == FALSE) == TRUE
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [49] FALSE FALSE NA FALSE FALSE FALSE FALSE
mpol %>%
slice(51) %>%
st_is_valid()
[1] NA
mpol %>%
slice(51)
Create valid geometry
mpol %>%
slice(51) %>%
st_cast("MULTIPOINT") %>%
distinct() %>%
st_make_valid() %>%
concaveman() %>%
st_cast("POLYGON") %>%
mutate(fid = as.character(14640001)) %>%
rename(geom = polygons) %>%
st_zm() -> p51
Replace valid geometry / Remove empty geometry
mpol %>%
filter(!row_number() %in% c(1, 51)) -> s51
s51 %>%
rbind(p51) -> mpol1
oct18 %>%
st_set_crs(27700) %>%
rename(fid = X3_Functional_Unit_Co) %>%
select(fid) -> oct181
npol %>%
rename(geom = geometry) -> npol
oct181 %>%
slice(10:20)
oct181 %>%
filter(!st_is_empty(.)) -> oct181
rbind(oct181, npol, mpol1) -> allP
Summary of joined polygons
allP %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
summarise(Total = n(),
FUCs = n_distinct(FUC),
NA_FUCs = sum(is.na(FUC))) %>%
adorn_totals()
Some FUCs are duplicated?
allP %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) %>%
adorn_totals()
tmap_mode("view")
allP %>%
rename(FUC = fid) %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) %>%
tm_shape() +
tm_polygons()
allP %>%
st_drop_geometry() %>%
rename(FUC = fid) %>%
group_by(FUC) %>%
count() %>%
arrange(desc(n)) %>%
filter(n > 1) -> dup
dup
# filter duplicated and calculate area - keep largest area
allP %>%
rename(FUC = fid) %>%
filter(FUC %in% dup$FUC) %>%
mutate(area = st_area(.)) %>%
arrange(FUC) %>%
group_by(FUC) %>%
slice(which.max(area)) %>%
select(FUC) -> Ldup
Ldup
# remove duplicated
allP %>%
rename(FUC = fid) %>%
filter(!FUC %in% dup$FUC) -> Ndup
rbind(Ldup, Ndup) %>%
st_cast("MULTIPOLYGON") %>%
ungroup() -> fP
Final summary fP
fP %>%
st_drop_geometry() %>%
summarise(Total = n(),
FUCs = n_distinct(FUC),
NA_FUCs = sum(is.na(FUC))) %>%
adorn_totals()
#st_write(fP, "fP.gpkg")
Keep Codex as U_ID
REDACTED_164_OKR Survey_WMT 2019 business base_191104 | OKR survey (spreadsheet with point data)
okr <- read_excel("~/Documents/SINDA_local/data_from_southwark/WMT OKR Business Survey 2019/REDACTED_164_OKR Survey_WMT 2019 business base_191104.xlsx",
col_types = c("text", "numeric", "text",
"text", "text", "text", "text", "numeric",
"text", "text", "text", "text", "text",
"text", "text", "text", "text", "text",
"text", "text", "text", "text", "text",
"text", "text", "numeric", "numeric",
"numeric", "numeric", "text", "text",
"text", "text", "text", "text", "text",
"text", "numeric", "text", "numeric",
"text", "text", "text", "numeric",
"numeric", "numeric", "numeric"))
okr_sf <- okr %>%
#select(1:37) %>%
st_as_sf(., coords = c("Xcoord", "Ycoord"), na.fail = F, crs = 27700) %>%
filter(Join != 234) %>% # filter point in Australia Join 234.0
mutate(newFUC = paste0('OKR-', 1:nrow(.)))
qtm(okr_sf, fill = "tomato")
okr_sf %>%
select(codex) -> fPi